package com.app.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by xinjian.hu on 18-2-11.
 */
@Repository
public class redisDao {
    @Autowired
    private RedisTemplate<String, String> stringRedisTemplate;


    public List<String> getValues(List<String> keys) {
        return stringRedisTemplate.opsForValue().multiGet(keys);
    }


    public void setValues(Map<String, String> values) {
        stringRedisTemplate.opsForValue().multiSet(values);
        ;
    }

    /*
     * (non-Javadoc)
     *
     * @see core.dao.RedisDao#setString(java.lang.String, java.lang.String)
     */
    public void setValue(String key, String value) {
        stringRedisTemplate.opsForValue().set(key, value);
    }

    /*
     * (non-Javadoc)
     *
     * @see core.dao.RedisDao#getString(java.lang.String)
     */
    public String getValue(String key) {
        return stringRedisTemplate.opsForValue().get(key);
    }

    /*
     * (non-Javadoc)
     *
     * @see core.dao.RedisDao#getString(java.lang.String)
     */
    public void deleteValue(String key) {
        stringRedisTemplate.delete(key);
    }

}
